using System;
using System.Collections;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;

namespace GameEngine.Cameras
{
    /// <summary>
    /// The camera manager - you can add cameras, return them and set their viewports
    /// </summary>
    public class GECameraManager
    {
        private static Hashtable Cameras = new Hashtable();
        private static GECamera activeCamera;

        public static GECamera ActiveCamera { get { return activeCamera; } }

        /// <summary>
        /// Add a camera
        /// </summary>
        /// <param name="cameraName">The name of the camera, so as to be able to identify it</param>
        /// <param name="camera">The camera to add</param>
        public static void AddCamera(string cameraName, GECamera camera)
        {
            if (cameraName != "")
                Cameras.Add(cameraName, camera);
        }

        /// <summary>
        /// Set the active camera for drawing
        /// </summary>
        /// <param name="cameraName">The name of the camera, that it was added as</param>
        public static void SetActiveCamera(string cameraName)
        {
            if (cameraName != null && Cameras.Contains(cameraName))
                activeCamera = Cameras[cameraName] as GECamera;
        }

        /// <summary>
        /// Updates all of the cameras to use the specified viewport
        /// </summary>
        /// <param name="newViewport"></param>
        public static void UpdateViewPorts(Viewport newViewport)
        {
            foreach (GECamera camera in Cameras.Values)
            {
                camera.SetViewport(newViewport);
            }
        }
    }
}
